#include <stdio.h>
int count(char a[], int sum)
{
    int cnt = 0;
    if (a[0] >= '2' && a[0] <= '9')
        sum += a[0] - '0';
    else
    {
        if (a[0] == 'A')
        {
            cnt++;
            sum += 11;
        }
        else
            sum += 10;
    }
    if (sum > 21 && cnt)
        sum -= 10;
    return sum;
}
int main()
{
    char s[3];
    int sum = 0;
    scanf("%s", s);
    while (s[0] != '-')
    { //输入-1停止
        sum = count(s, sum);
        for (int i = 0; i < 2; i++)
        {
            scanf("%s", s);
            sum = count(s, sum);
        }
        printf("%d\n", sum);
        scanf("%s", s);
    }
    return 0;
}